package test;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;

public class IOCopyFile {
    public static void main(String[] args) throws IOException {
        //优化文件复制
        //1.创建文件输入流
        FileInputStream fis = new FileInputStream("C:\\Users\\liuhe\\Videos\\Captures\\messi.mp4");
        //2.创建文件输出流
        FileOutputStream fos = new FileOutputStream("IODemo\\messe1.mp4");
        //3.循环读写
        //3.1编写每次读写的量
        byte[] bytes = new byte[1024 * 1024 * 8];
        //3.2定义变量防止读取有误
        int len;
        while((len = fis.read(bytes)) != -1){
            fos.write(bytes);
        }
        //4.释放资源
        fos.close();
        fis.close();

    }
}
